//
//  WDGoutWaitVehicleServiceInfoView.m
//  wd-serviceapp
//
//  Created by Bin Tang on 2025/3/27.
//

#import "WDGoutWaitVehicleServiceInfoView.h"
#import "WDArrivalServiceDetailModel.h"

@interface WDGoutWaitVehicleServiceInfoView ()
@property (nonatomic, strong) WDArrivalServiceDetailModel *taskDetailModel;

/// 创建时间
@property (nonatomic, strong) WDTaskDetailBasicSingleView *createTimeView;

/// 抢单时间
@property (nonatomic, strong) WDTaskDetailBasicSingleView *robOrderTimeView;

/// 抢单账号
@property (nonatomic, strong) WDTaskDetailBasicSingleView *robOrderAccountView;


/// 创建时间
- (void)initWithCreateTimeView;

/// 抢单时间
- (void)initWithRobOrderTimeView;

/// 抢单账号
- (void)initWithRobOrderAccountView;


@end

@implementation WDGoutWaitVehicleServiceInfoView

- (void)initWithSubView {
    [super initWithSubView];
    self.backgroundColor = [UIColor whiteColor];
}

/// 创建时间
- (void)initWithCreateTimeView {
    if (!_createTimeView) {
        CGRect frame = CGRectMake(0, 0, self.width, kWDTaskDetailBasicSingleViewHeight);
        _createTimeView = [[WDTaskDetailBasicSingleView alloc] initWithFrame:frame];
        [self addSubview:_createTimeView];
    }
    if (self.taskDetailModel) {
        [_createTimeView updateWithViewTitle:@"创建时间" value:self.taskDetailModel.createTime valueHeight:18];
    }
}

/// 抢单时间
- (void)initWithRobOrderTimeView {
    if (!_robOrderTimeView) {
        CGRect frame = self.createTimeView.frame;
        frame.origin.y = self.createTimeView.bottom;
        _robOrderTimeView = [[WDTaskDetailBasicSingleView alloc] initWithFrame:frame];
        [self addSubview:_robOrderTimeView];
    }
    if (self.taskDetailModel) {
        [_robOrderTimeView updateWithViewTitle:@"抢单时间" value:self.taskDetailModel.asignTime valueHeight:18];
    }
}

/// 抢单账号
- (void)initWithRobOrderAccountView {
    if (!_robOrderAccountView) {
        CGRect frame = self.robOrderTimeView.frame;
        frame.origin.y = self.robOrderTimeView.bottom;
        _robOrderAccountView = [[WDTaskDetailBasicSingleView alloc] initWithFrame:frame];
        [self addSubview:_robOrderAccountView];
    }
    if (self.taskDetailModel) {
        WDTaskFlowModel *flowModel = self.taskDetailModel.taskFlowList.firstObject;
        [_robOrderAccountView updateWithViewTitle:@"抢单账号" value:objectNull(flowModel.engineerName) valueHeight:18];
    }
}


- (void)updateWithViewData:(id)data {
    self.taskDetailModel = data;
    
    [self initWithCreateTimeView];

    [self initWithRobOrderTimeView];

    [self initWithRobOrderAccountView];
}

@end
